$(function () {
    getListInfo();
});

function getListInfo() {
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/getListInfo",
        data:{
            "projectCategory":$("#projectCategory").val()
        },
        type: "POST",
        success: function (data) {
            var text = '';
            for(var i=0 ; i<data.length ; i++){
                text += '<div><label style="font-weight: 500;margin:0;"><input type="checkbox" name="about" style="vertical-align: middle;margin: 0 8px 0;" value="'+data[i].projectName+'" >'+data[i].projectName+'</label></div>'
            }
            $("#projectType2").html(text);
            var payService = $("#payService").val();
            if (payService != "" && payService != null) {
                var arr = payService.split(",");
                for (var i = 0; i < arr.length; i++) {
                    $("input[type='checkbox'][name='about'][value=" + arr[i] + "]").attr('checked', true);
                }
            }
        }
    })
}

function updAppointmentPayServiceOK(){
    var customerId = document.getElementById("customerId").value;
    var check = $("input[type='checkbox']:checked");
    var projectData = "";
    for (var i = 0; i < check.length; i++) {
        projectData += $(check[i]).val() + ",";
    }
    $.ajax({
        url: Feng.ctxPath + "/doctorLooked/updAppointmentPayServiceOK",
        type: "post",
        data: {
            "customerId": customerId,
            "projectData": projectData
        },
        success: function (data) {
            Feng.success('修改成功!');
            window.parent.$('#calendar').fullCalendar('refetchEvents');
            parent.layer.close(parent.layer.getFrameIndex(window.name))
        },
        error: function (data) {
            Feng.success('修改失败!');
        }
    });
}